function Bik_u = My_BaseFunction(i , k , u , NodeVector)
% B样条基函数

if k == 1 % 1阶B样条
    if u >= NodeVector(i) && u <= NodeVector(i+1)
        Bik_u = 1;
    else
        Bik_u = 0;
    end
else
    denominator1 = NodeVector(i+k-1) - NodeVector(i); % 第一项的分母
    denominator2 = NodeVector(i+k) - NodeVector(i+1) ; % 第二项的分母
    if denominator1 == 0
        denominator1 = 1;
    end
    if denominator2 == 0
        denominator2 = 1;
    end
    Bik_u = (u - NodeVector(i)) / denominator1 * My_BaseFunction(i , k-1 , u , NodeVector)...
            +(NodeVector(i+k) - u)/denominator2 * My_BaseFunction(i+1 , k-1 , u , NodeVector);
end


